import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../layout/index'

Vue.use(Router)

export const constantRouterMap = [
  // {
  //   path: '/login',
  //   meta: { title: '登录', noCache: true },
  //   component: resolve => require(['@/views/login'], resolve),
  //   hidden: true
  // },
  {
    path: '/phone-login',
    meta: { title: '登录', noCache: true },
    component: resolve => require(['@/views/phone-login'], resolve),
    hidden: true
  },
  {
    path: '/share-article',
    meta: { title: '文章', noCache: true },
    component: resolve =>
      require(['@/views/system/share-article/index'], resolve),
    hidden: true
  },
  {
    path: '/share-notice',
    meta: { title: '通知', noCache: true },
    component: resolve =>
      require(['@/views/system/share-notice/index'], resolve),
    hidden: true
  },
  {
    path: '/app-intro',
    meta: { title: '问易得', noCache: true },
    component: resolve =>
      require(['@/views/system/app-intro/index'], resolve),
    hidden: true
  },
  {
    path: '/share-info',
    meta: { title: '问易得', noCache: true },
    component: resolve =>
      require(['@/views/system/share-info/index'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: resolve => require(['@/views/features/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: resolve => require(['@/views/features/401'], resolve),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: resolve => require(['@/views/features/redirect'], resolve)
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: resolve => require(['@/views/home'], resolve),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'index', affix: true, noCache: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'center',
        component: resolve => require(['@/views/system/user/center'], resolve),
        name: '个人中心',
        meta: { title: '个人中心' }
      },
      {
        path: 'children/:id',
        component: resolve =>
          require(['@/views/system/user/children'], resolve),
        name: '下级列表',
        meta: { title: '下级列表' }
      }
    ]
  },
  {
    path: '/article',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'detail',
        component: resolve =>
          require(['@/views/system/article-detail/index'], resolve),
        name: '文章详情',
        meta: { title: '文章详情' }
      }
    ]
  },
  {
    path: '/notice',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'detail',
        component: resolve =>
          require(['@/views/system/notice/notice-detail'], resolve),
        name: '公告详情',
        meta: { title: '公告详情' }
      }
    ]
  },
  {
    path: '/query',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'answer',
        component: resolve =>
          require(['@/views/system/query/answer-query'], resolve),
        name: '回答咨询',
        meta: { title: '回答咨询' }
      }
    ]
  }
]

export default new Router({
  // mode: 'hash',
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
